cmake_minimum_required(VERSION 3.10)
project(Tool)

# 设置C++标准
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# 指定输出目录
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)

# 添加头文件路径
include_directories(include)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
    set(TOOLS_NAME "Tools_d")
else()
    set(TOOLS_NAME "Tools")
endif()

# 定义源文件列表
# set(TOOLS_SOURCES
#     Config.cpp
#     ConfigIni.cpp
#     ConfigJson.cpp
#     ILogger.cpp
#     Variant.cpp
#     Logger.cpp
#     Loggers.cpp
#     Program.cpp
#     Randomm.cpp
#     Timer.cpp
#     DataTime.cpp
#     ThreadPool.cpp
#     TcpClient.cpp
#     TcpServer.cpp
#     EventLoop.cpp
#     MiniDatabase.cpp
# )
file(GLOB TOOLS_SOURCES "*.cpp")

# 创建共享库
add_library(${TOOLS_NAME} SHARED ${TOOLS_SOURCES})
# 创建静态库
# add_library(${TOOLS_NAME}_static STATIC ${TOOLS_SOURCES})

if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
    target_link_libraries(${TOOLS_NAME} PRIVATE ws2_32)
endif()

# 设置全局属性，以便于Release模式下也能生成调试符号
# set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi")
# set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF")

# 为目标定义MYLIBRARY_EXPORTS宏
add_definitions(-DTOOL_LIBRARY)
target_compile_definitions(${TOOLS_NAME} PRIVATE TOOL_LIBRARY)

# 如果有安装步骤，可以添加install命令
install(TARGETS ${TOOLS_NAME} DESTINATION lib)
install(DIRECTORY include/ DESTINATION include)